package com.tutorial.advice;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;

import java.lang.reflect.Method;

/**
 * 实现了前置通知和后置通知接口
 * className: MyAdvice1
 * author: GXW
 * date: 2025/7/24 15:04:09
 * description: TODO 实现了前置通知和后置通知接口
 */
public class MyAdvice1 implements MethodBeforeAdvice, AfterReturningAdvice {
	/**
	 * @param returnValue the value returned by the method, if any
	 * @param method      the method being invoked
	 * @param args        the arguments to the method
	 * @param target      the target of the method invocation. May be {@code null}.
	 * @throws Throwable
	 */
	@Override
	public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
		System.out.println("This is afterReturn advice......");
	}

	/**
	 * @param method the method being invoked
	 * @param args   the arguments to the method
	 * @param target the target of the method invocation. May be {@code null}.
	 * @throws Throwable
	 */
	@Override
	public void before(Method method, Object[] args, Object target) throws Throwable {
		System.out.println("This is beforeReturn advice......");
	}
}
